package com.vctgo.subject.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.vctgo.common.core.text.Convert;
import com.vctgo.common.core.utils.ServletUtils;
import com.vctgo.common.mybatisplus.constant.MybatisPageConstants;
import com.vctgo.subject.domain.TbSubject;
import com.vctgo.subject.mapper.TbSubjectMapper;
import com.vctgo.subject.service.ITbSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
/**
 * 科目/期初Service业务层处理
 *
 * @author zhx
 * @date 2024-12-16
 */
@Service
public class TbSubjectServiceImpl implements ITbSubjectService
{
    @Autowired
    private TbSubjectMapper tbSubjectMapper;

    /**
     * 查询科目/期初
     *
     * @param id 科目/期初主键
     * @return 科目/期初
     */
    @Override
    public TbSubject selectTbSubjectById(Long id)
    {
        return tbSubjectMapper.selectById(id);
    }

    /**
     * 查询科目/期初列表-分页
     *
     * @param tbSubject 科目/期初
     * @return 科目/期初
     */
    @Override
    public IPage<TbSubject> selectTbSubjectPage(TbSubject tbSubject)
    {
        Page mpPage =new Page(Convert.toLong(ServletUtils.getParameterToInt(MybatisPageConstants.PAGE_NUM),1L)
                ,Convert.toLong(ServletUtils.getParameterToInt(MybatisPageConstants.PAGE_SIZE),10L));
        return tbSubjectMapper.selectTbSubjectList(mpPage,tbSubject);
    }
    /**
     * 查询科目/期初列表
     *
     * @param tbSubject 科目/期初
     * @return 科目/期初
     */
    @Override
    public List<TbSubject> selectTbSubjectList(TbSubject tbSubject)
    {
        return tbSubjectMapper.selectTbSubjectList(tbSubject);
    }

    /**
     * 新增科目/期初
     *
     * @param tbSubject 科目/期初
     * @return 结果
     */

    @Override
    public int insertTbSubject(TbSubject tbSubject)
    {
        return tbSubjectMapper.insert(tbSubject);
    }

    /**
     * 修改科目/期初
     *
     * @param tbSubject 科目/期初
     * @return 结果
     */
    @Override
    public int updateTbSubject(TbSubject tbSubject)
    {
        return tbSubjectMapper.updateById(tbSubject);
    }

    /**
     * 批量删除科目/期初
     *
     * @param ids 需要删除的科目/期初主键
     * @return 结果
     */
    @Override
    public int deleteTbSubjectByIds(Long[] ids)
    {
        return tbSubjectMapper.deleteTbSubjectByIds(ids);
    }

    /**
     * 删除科目/期初信息
     *
     * @param id 科目/期初主键
     * @return 结果
     */
    @Override
    public int deleteTbSubjectById(Long id)
    {
        return tbSubjectMapper.deleteById(id);
    }

    @Override
    public List<TbSubject> selectSubjectList() {
        return tbSubjectMapper.selectSubjectList();
    }
}
